package com.tju.resource.oauth.controller.menu;

import com.tju.resource.tool.result.Result;
import com.tju.resource.tool.result.ResultEnum;
import com.tju.resource.tool.result.ResultUtil;
import com.tju.resource.tool.tool.ClientParameters;
import com.tju.resource.server.SysPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author CLS
 * @Date 2022/1/5 18:21
 */
@RestController
public class HomeController {

    private static final String prefix = "home";

    @Autowired
    private SysPermissionService permissionService;

    @PostMapping(prefix + "/sys/power/menu")
    public Result<Object> sysPowerMenu(@RequestBody ClientParameters permission) {
        if (permission.getUgc() != null) {
            return permissionService.getMenusByUserName(permission.getUgc());
        } else
            return ResultUtil.error(ResultEnum.UNKONW_ERROR);
    }

}
